<template>
	<u-modal v-model="show" :show-cancel-button="true" confirm-text="确定" title="温馨提示" @cancel="cancel" @confirm="confirm">
		<view class="u-update-content">
			<rich-text :nodes="content"></rich-text>
		</view>
	</u-modal>
</template>

<script>
	export default {
		data() {
			return {
				show: true,
				content: `<div style="text-align: center;">你确定接收该单吗?</div>`,
				id:0,
				number:''
			}
		},
		onShow() {
			this.show = true;
		},
		methods: {
			cancel() {
				this.closeModal();
			},
			async confirm() {
				console.log('按下确定')
				const res = await uni.request({
					url:`http://127.0.0.1:8080/selectTask?id=${this.id}&number=${this.number}`
				})
				console.log(res)
				if(res[1].data.code == 0){
					uni.$emit('Add_Task')
					uni.navigateBack({
						delta:2
					})
				}else{
					uni.showModal({
						title:'温馨提示',
						content:'该订单为自己发布的任务',
						showCancel:false,
						success:()=> {
							this.closeModal();
						}
					})
				}
			},
			closeModal() {
				uni.navigateBack();
			}
		},
		onLoad(options) {
			this.id = options.id;
			this.number = options.number;
			console.log(this.id,this.number)
		}
	}
</script>

<style scoped lang="scss">
	.u-full-content {
		background-color: #00C777;
	}
	
	.u-update-content {
		font-size: 26rpx;
		color: $u-content-color;
		line-height: 1.7;
		padding: 30rpx;
	}
</style>
